<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
 * Description of responseToClient
 eg.
    $r2c = new responseToClient(response);
 or  
    $r2c = new responseToClient();
  
    $r2c->javascript = array(
        'code_id'=>'',
        'code'=>'',
        'parent_id'=>'',
    );
                
    $r2c->html = array(
        'code_id'=>'',
        'code'=>'',
        'parent_id'=>'',
    );

    $r2c->css = array(
        'code_id'=>'',
        'code'=>'',
        'parent_id'=>'',
    );
    $r2c->errors = array();
    $r2c->data = $_POST;
    $r2c->post=$_POST;
   
    $r2c->send();
   
 *
 * @todo 
 * 
 * @author George Zeakis<zeageorge@google.com>
 * 
 */
class responseToClient extends dynamicContainer{
    
    function __construct(array $response=array()) {
        parent::__construct();
        
        if (!empty($response)){
            $this->_container = $response;
        }
        
    }
    
    public function send(array $data=array()){
        header('Content-type: application/json');
        if (empty($data)){
            echo json_encode($this->toArray());
        } else {
           echo json_encode($data);
        }
    }
    
    public function toArray(){
        return $this->_container;
    }
    
    function __destruct() { 
        parent::__destruct();
    }
}

?>
